package com.shuodao.cokeps.config;

import java.io.File;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Repository;

import com.shuodao.cokeps.util.IPDataUtil;
import com.shuodao.common.config.CommonConfig;

@Repository
public class YamlConfig {
	
	public String weixin_site;
	public String site_id;
	public String api_key;
	public String app_id;
	
	public String templateId;
	public String msg_sign_name;
	
	public String domain_url;
	
	public String print_url;
	
	public String udp_port;
	
	@PostConstruct
	private void init(){
		YamlConfig config = CommonConfig.loadConfig(YamlConfig.class);
		this.weixin_site = config.weixin_site;
		this.site_id = config.site_id;
		this.api_key = config.api_key;
		this.app_id = config.app_id;
		
		this.templateId = config.templateId;
		this.msg_sign_name = config.msg_sign_name;
		
		this.domain_url = config.domain_url;
		
		this.print_url = config.print_url;
		
		this.udp_port = config.udp_port;
		
		IPDataUtil.load(new File(CommonConfig.getWebInfDir(), "ip_db.dat"));
	}
	
	public static YamlConfig config;
	
	public static YamlConfig getInstance(){
		return config;
	}
	
}
